<html>
<head><meta charset="utf-8"><title>const pattern match semantics #67343 · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html">const pattern match semantics #67343</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="195628438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195628438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195628438">(Apr 28 2020 at 21:18)</a>:</h4>
<p>I honestly cannot remember to what level of detail we had discussed this, so I wanted to try to check here first:</p>



<a name="195628612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195628612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195628612">(Apr 28 2020 at 21:20)</a>:</h4>
<p>I am pretty sure we had previously agreed to adopt <span class="user-mention" data-user-id="118594">@ecstatic-morse</span> 's approach for using a MIR "value-based" semantics for validating that all parts of a <code>const</code> in a pattern match implement <code>PartialEq</code> and <code>Eq</code> via <code>#[derive(..)]</code></p>



<a name="195628648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195628648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195628648">(Apr 28 2020 at 21:20)</a>:</h4>
<p>But the thing I am not certain about is whether we had all agreed that we were okay with using a value-based semantics across crate boundaries</p>



<a name="195628679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195628679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195628679">(Apr 28 2020 at 21:21)</a>:</h4>
<p>(the main alternative I could imagine is to use a type-based semantics across crate boundaries)</p>



<a name="195628897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195628897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195628897">(Apr 28 2020 at 21:23)</a>:</h4>
<p>I guess the point of this is that whether crate authors will realize that changing the value of a <code>const</code> item such that it becomes not structurally-matchable will break downstream crates.</p>



<a name="195628960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195628960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195628960">(Apr 28 2020 at 21:23)</a>:</h4>
<p>I have no memory of this :)</p>



<a name="195628972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195628972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195628972">(Apr 28 2020 at 21:23)</a>:</h4>
<p>but at this point I just want it resolved</p>



<a name="195628996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195628996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195628996">(Apr 28 2020 at 21:23)</a>:</h4>
<p>The relevant note from PR <a href="https://github.com/rust-lang/rust/issues/67343" title="https://github.com/rust-lang/rust/issues/67343">#67343</a> is in its description; I will copy it here for ease of reference: </p>
<blockquote>
<p>AFAIK, it's not settled that these are the semantics we actually want: it's just how the <code>Qualif</code> framework happens to work. If the cross-crate part is undesirable, it would be quite easy to change the result of <code>mir_const_qualif().custom_eq</code> to <code>true</code> before encoding it in the crate metadata. This way, other crates would have to assume that all publicly exported constants may not be safe for matching.</p>
</blockquote>



<a name="195629003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629003">(Apr 28 2020 at 21:24)</a>:</h4>
<p>that said, I do think that -- in general -- one canot change const values without breakage, right?</p>



<a name="195629050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629050">(Apr 28 2020 at 21:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629003" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629003">said</a>:</p>
<blockquote>
<p>that said, I do think that -- in general -- one canot change const values without breakage, right?</p>
</blockquote>
<p>I was indeed wondering that as I was typing</p>



<a name="195629076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629076">(Apr 28 2020 at 21:24)</a>:</h4>
<p>and if that is the case, then maybe I am making a mountain out of a molehill</p>



<a name="195629095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629095">(Apr 28 2020 at 21:24)</a>:</h4>
<p>well, it comes I guess to how we wind up settling on equality <em>but</em></p>



<a name="195629138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629138">(Apr 28 2020 at 21:25)</a>:</h4>
<p>In any case, I get the impression that it would be quite easy for <span class="user-mention" data-user-id="118594">@ecstatic-morse</span> to adopt the more conservative semantics</p>



<a name="195629192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629192">(Apr 28 2020 at 21:25)</a>:</h4>
<p>this builds for sure</p>
<div class="codehilite"><pre><span></span><code><span class="k">const</span><span class="w"> </span><span class="n">A</span>: <span class="kt">usize</span> <span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span><span class="w"></span>
<span class="k">const</span><span class="w"> </span><span class="n">B</span>: <span class="kt">usize</span> <span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">x</span>: <span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="n">A</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">];</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span>: <span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="n">B</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="p">];</span><span class="w"></span>
<span class="w">    </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">y</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="195629205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629205">(Apr 28 2020 at 21:25)</a>:</h4>
<p>and I guess the same is true across crates</p>



<a name="195629208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629208">(Apr 28 2020 at 21:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629095" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629095">said</a>:</p>
<blockquote>
<p>well, it comes I guess to how we wind up settling on equality <em>but</em></p>
</blockquote>
<p>hmm, I had thought in either case (with or without cross-crate support), we would still be equally able to support structural or semantic equality, no?</p>



<a name="195629318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629318">(Apr 28 2020 at 21:26)</a>:</h4>
<p>I remember talking about this topic a lot with <span class="user-mention" data-user-id="228094">@Ariel Ben-Yehuda</span> and <span class="user-mention" data-user-id="119009">@eddyb</span> years back but I kind of lost track on this question</p>



<a name="195629342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629342">(Apr 28 2020 at 21:26)</a>:</h4>
<p>My suspicion is that this is fine</p>



<a name="195629357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629357">(Apr 28 2020 at 21:26)</a>:</h4>
<p>to me it's always been the "key" thing to think and discuss with const generics so I'm frustrated that I don't have a crisp articulation of the current thinking :)</p>



<a name="195629411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629411">(Apr 28 2020 at 21:27)</a>:</h4>
<p>i.e. that supporting the cross-crate thing here is fine. (In particular, I'm betting that if there was some problem with it, <span class="user-mention" data-user-id="119009">@eddyb</span> would have raised a ruckus with respect to this PR a long time ago...)</p>



<a name="195629412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629412">(Apr 28 2020 at 21:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629208" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629208">said</a>:</p>
<blockquote>
<p>hmm, I had thought in either case (with or without cross-crate support), we would still be equally able to support structural or semantic equality, no?</p>
</blockquote>
<p>I'm not sure I understand</p>



<a name="195629459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629459">(Apr 28 2020 at 21:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629412" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629412">said</a>:</p>
<blockquote>
<p>I'm not sure I understand</p>
</blockquote>



<a name="195629475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629475">(Apr 28 2020 at 21:27)</a>:</h4>
<p>well</p>



<a name="195629557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629557">(Apr 28 2020 at 21:28)</a>:</h4>
<p>the linked PR is still in service of us being ambivalent of the choice between structural or semantic equality for consts in patterns</p>



<a name="195629572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629572">(Apr 28 2020 at 21:28)</a>:</h4>
<p>and thus</p>



<a name="195629575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629575">(Apr 28 2020 at 21:28)</a>:</h4>
<p>I had figured</p>



<a name="195629589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629589">(Apr 28 2020 at 21:28)</a>:</h4>
<p>even if it allows the more expressive form across crates</p>



<a name="195629599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629599">(Apr 28 2020 at 21:28)</a>:</h4>
<p>it is <em>still</em> going to be something where the only code that is accepted</p>



<a name="195629662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629662">(Apr 28 2020 at 21:29)</a>:</h4>
<p>is code that is compatible with structural match or use of <code>PartialEq::eq</code> for its semantics</p>



<a name="195629698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629698">(Apr 28 2020 at 21:29)</a>:</h4>
<p>I see</p>



<a name="195629749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629749">(Apr 28 2020 at 21:30)</a>:</h4>
<p>Something else that I had realized, forgotten, and that I am now re-remembering</p>



<a name="195629782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629782">(Apr 28 2020 at 21:30)</a>:</h4>
<p>is that equality in const generics</p>



<a name="195629788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629788">(Apr 28 2020 at 21:30)</a>:</h4>
<p>will presumably <em>not</em> be based on <code>PartialEq</code></p>



<a name="195629823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629823">(Apr 28 2020 at 21:30)</a>:</h4>
<p>but rather a different notion of equality</p>



<a name="195629844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629844">(Apr 28 2020 at 21:30)</a>:</h4>
<p>having said that, it will be pretty wild if we use structural semantics for constants that are defined like <code>const C = if TEST { E::Var1 } else { E::Var2 };</code></p>



<a name="195629856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629856">(Apr 28 2020 at 21:31)</a>:</h4>
<p>which is kind of neither here nor there <em>I guess</em></p>



<a name="195629877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629877">(Apr 28 2020 at 21:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629844" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629844">said</a>:</p>
<blockquote>
<p>having said that, it will be pretty wild if we use structural semantics for constants that are defined like <code>const C = if TEST { E::Var1 } else { E::Var2 };</code></p>
</blockquote>
<p>yes</p>



<a name="195629891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629891">(Apr 28 2020 at 21:31)</a>:</h4>
<p>similarly <code>const X = some_const_fn(...);</code></p>



<a name="195629898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629898">(Apr 28 2020 at 21:31)</a>:</h4>
<p>though you might want it, it's very unclear</p>



<a name="195629945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195629945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195629945">(Apr 28 2020 at 21:32)</a>:</h4>
<p>ooh boy</p>



<a name="195630013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630013">(Apr 28 2020 at 21:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629823" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629823">said</a>:</p>
<blockquote>
<p>but rather a different notion of equality</p>
</blockquote>
<p>was this due to floating point NaN issues? Or something else?</p>



<a name="195630243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630243">(Apr 28 2020 at 21:35)</a>:</h4>
<p>well</p>



<a name="195630273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630273">(Apr 28 2020 at 21:35)</a>:</h4>
<p>the obvious example is <code>impl PartialEq for MyType { fn is_eq(&amp;self) -&gt; bool { false } }</code></p>



<a name="195630297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630297">(Apr 28 2020 at 21:35)</a>:</h4>
<p>two things might be "equal" constants (same bitpatterns) but not equal at runtime</p>



<a name="195630304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630304">(Apr 28 2020 at 21:35)</a>:</h4>
<p>right</p>



<a name="195630312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630312">(Apr 28 2020 at 21:35)</a>:</h4>
<p>this is very "close" to the pattern questions</p>



<a name="195630313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630313">(Apr 28 2020 at 21:35)</a>:</h4>
<p>that's the classic example that I reference</p>



<a name="195630315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630315">(Apr 28 2020 at 21:35)</a>:</h4>
<p>but</p>



<a name="195630323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630323">(Apr 28 2020 at 21:35)</a>:</h4>
<p>I would think that</p>



<a name="195630363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630363">(Apr 28 2020 at 21:36)</a>:</h4>
<p>if we commit to so-called semantic equality</p>



<a name="195630374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630374">(Apr 28 2020 at 21:36)</a>:</h4>
<p>i.e. if we commit to dispatching to <code>PartialEq::eq</code></p>



<a name="195630379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630379">(Apr 28 2020 at 21:36)</a>:</h4>
<p>then all such matches on <code>MyType</code> will just fail?</p>



<a name="195630389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630389">(Apr 28 2020 at 21:36)</a>:</h4>
<p>but I'm talking about const generics equality</p>



<a name="195630404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630404">(Apr 28 2020 at 21:36)</a>:</h4>
<p>e.g., given <code>const C: MyType = ..</code>, are <code>Foo&lt;C&gt;</code> and <code>Foo&lt;C&gt;</code> equal types?</p>



<a name="195630418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630418">(Apr 28 2020 at 21:37)</a>:</h4>
<p>oh right</p>



<a name="195630428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630428">(Apr 28 2020 at 21:37)</a>:</h4>
<p>what about <code>Foo&lt;C&gt;</code> and <code>Foo&lt;D&gt;</code> where <code>C</code> and <code> D</code> are two distinct constants with same bit pattern</p>



<a name="195630433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630433">(Apr 28 2020 at 21:37)</a>:</h4>
<p>you all keep reconnecting these two things</p>



<a name="195630443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630443">(Apr 28 2020 at 21:37)</a>:</h4>
<p>they are distinct for sure</p>



<a name="195630446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630446">(Apr 28 2020 at 21:37)</a>:</h4>
<p>and I keep acting like we can treat <code>match</code> as living in its own little bubble</p>



<a name="195630454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630454">(Apr 28 2020 at 21:37)</a>:</h4>
<p>pattern matching is a runtime operation</p>



<a name="195630464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630464">(Apr 28 2020 at 21:37)</a>:</h4>
<p><em>but</em></p>



<a name="195630472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630472">(Apr 28 2020 at 21:37)</a>:</h4>
<p>I guess I'm just saying that we <em>will</em> have two notions of equality</p>



<a name="195630482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630482">(Apr 28 2020 at 21:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629782" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629782">said</a>:</p>
<blockquote>
<p>is that equality in const generics</p>
</blockquote>
<p>when you wrote this, I read it as "matching of associated consts"</p>



<a name="195630485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630485">(Apr 28 2020 at 21:37)</a>:</h4>
<p>and some of the concerns, e.g., wanting to know that we always have a place to branch to</p>



<a name="195630495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630495">(Apr 28 2020 at 21:37)</a>:</h4>
<p>or exhaustiveness etc</p>



<a name="195630498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630498">(Apr 28 2020 at 21:37)</a>:</h4>
<p>which is not at all what you wrote, of course</p>



<a name="195630544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630544">(Apr 28 2020 at 21:38)</a>:</h4>
<p>seem related</p>



<a name="195630573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630573">(Apr 28 2020 at 21:38)</a>:</h4>
<p>I guess it softens me to the "two notions" of equality, if we can make the "static-y" equality for const generics and pattern matching kind of line up</p>



<a name="195630574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630574">(Apr 28 2020 at 21:38)</a>:</h4>
<p>well my point is that in the end, we can always fall back on having <code>match</code> arms fail to fire</p>



<a name="195630604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630604">(Apr 28 2020 at 21:38)</a>:</h4>
<p>as long as there is an <code>_</code> arm...</p>



<a name="195630612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630612">(Apr 28 2020 at 21:38)</a>:</h4>
<p>sure</p>



<a name="195630637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630637">(Apr 28 2020 at 21:39)</a>:</h4>
<p>presumably the exhautiveness checker will give up in cases where you did not <code>derive</code> the <code>PartialEq</code> impl</p>



<a name="195630651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630651">(Apr 28 2020 at 21:39)</a>:</h4>
<p>I'm sort of looking for an excuse to give up and embrace the "syntactic equality", I guess :)</p>



<a name="195630654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630654">(Apr 28 2020 at 21:39)</a>:</h4>
<p>and thus you will get errors if you leave out <code>_ =&gt; ...</code></p>



<a name="195630676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630676">(Apr 28 2020 at 21:39)</a>:</h4>
<p>Wouldn't it be great</p>



<a name="195630681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630681">(Apr 28 2020 at 21:39)</a>:</h4>
<p>if we used NaN</p>



<a name="195630687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630687">(Apr 28 2020 at 21:39)</a>:</h4>
<p>as an excuse</p>



<a name="195630698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630698">(Apr 28 2020 at 21:39)</a>:</h4>
<p>to embrace syntactic equality</p>



<a name="195630755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630755">(Apr 28 2020 at 21:40)</a>:</h4>
<p>such totally unrelated linguistic elements</p>



<a name="195630789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630789">(Apr 28 2020 at 21:40)</a>:</h4>
<p>but also</p>



<a name="195630812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630812">(Apr 28 2020 at 21:40)</a>:</h4>
<p>hmm</p>



<a name="195630831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630831">(Apr 28 2020 at 21:40)</a>:</h4>
<p>/me wonders about the <code>Foo&lt;C&gt;</code> example</p>



<a name="195630922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630922">(Apr 28 2020 at 21:42)</a>:</h4>
<p>like, okay: You go ahead and put in non equivalence relation as your <code>impl PartialEq for MyType</code> ... So in the worst case, if we <em>did</em> use semantic equality even at the type level</p>



<a name="195630976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195630976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195630976">(Apr 28 2020 at 21:42)</a>:</h4>
<p>(and, i dunno, used miri within the type checker)</p>



<a name="195631009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631009">(Apr 28 2020 at 21:42)</a>:</h4>
<p>ignoring the engineering issues that arise</p>



<a name="195631023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631023">(Apr 28 2020 at 21:42)</a>:</h4>
<p>Just in terms of user experience: What's the worst that happens?</p>



<a name="195631031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631031">(Apr 28 2020 at 21:43)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195628648" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195628648">said</a>:</p>
<blockquote>
<p>But the thing I am not certain about is whether we had all agreed that we were okay with using a value-based semantics across crate boundaries</p>
</blockquote>
<p>When we discussed it in the meeting, that topic didn't come up at all. I do personally agree that cross-crate doesn't need special handling.</p>



<a name="195631166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631166">(Apr 28 2020 at 21:44)</a>:</h4>
<p>Someone sees some truly bonkers behavior where the compiler rejects things like the assignment <code>x = x;</code> because the type-checker claims typeof(x) != typeof(x) ?</p>



<a name="195631205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631205">(Apr 28 2020 at 21:44)</a>:</h4>
<p>The main problem I see there is that, ideally, you'd want very specific feedback about <em>why</em> the expected and actual types are different</p>



<a name="195631218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631218">(Apr 28 2020 at 21:44)</a>:</h4>
<p>yeah but also</p>



<a name="195631242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631242">(Apr 28 2020 at 21:45)</a>:</h4>
<p>if you have a <code>PartialEq</code> whose comparison function is not a <code>const fn</code></p>



<a name="195631250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631250">(Apr 28 2020 at 21:45)</a>:</h4>
<p>it can't be compared</p>



<a name="195631265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631265">(Apr 28 2020 at 21:45)</a>:</h4>
<p>so we either have to forbid those types from being used as const generics..</p>



<a name="195631285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631285">(Apr 28 2020 at 21:45)</a>:</h4>
<p>I think that was what bothered me, that it introduced a kind of "class" of types</p>



<a name="195631287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631287">(Apr 28 2020 at 21:45)</a>:</h4>
<p>that is sort of ad-hoc</p>



<a name="195631362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631362">(Apr 28 2020 at 21:46)</a>:</h4>
<p>I assume in this hypothetical universe, people would actually <em>declare</em> their partial eq method to be a <code>const fn</code></p>



<a name="195631370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631370">(Apr 28 2020 at 21:46)</a>:</h4>
<p>it would not be e.g. inferred from the structure of its body</p>



<a name="195631487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631487">(Apr 28 2020 at 21:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195631031" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195631031">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195628648" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195628648">said</a>:</p>
<blockquote>
<p>But the thing I am not certain about is whether we had all agreed that we were okay with using a value-based semantics across crate boundaries</p>
</blockquote>
<p>When we discussed it in the meeting, that topic didn't come up at all. I do personally agree that cross-crate doesn't need special handling.</p>
</blockquote>
<p>Okay I'm glad I brought this up, at least. I don't know whether we need to make it part of this week's agenda, but I suppose it woudn't hurt. I <em>don't</em> think we need to block landing this PR on it.</p>



<a name="195631544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631544">(Apr 28 2020 at 21:47)</a>:</h4>
<p>(because I believe that it would be easy to toggle to the other semantics if we did decide in the meeting that would be preferable.)</p>



<a name="195631578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631578">(Apr 28 2020 at 21:47)</a>:</h4>
<p>I'll add this as an agenda item.</p>



<a name="195631673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Asa Zeren <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631673">(Apr 28 2020 at 21:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195631362" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195631362">said</a>:</p>
<blockquote>
<p>I assume in this hypothetical universe, people would actually <em>declare</em> their partial eq method to be a <code>const fn</code></p>
</blockquote>
<p>How would that interact with #[derive(PartialEq)]? Would the derived impl be const sometimes, always, or never.</p>



<a name="195631757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631757">(Apr 28 2020 at 21:49)</a>:</h4>
<p>... hmm. I had assumed that if you were able to make arbitrary methods of an impl into <code>const fn</code> (assuming their bodies were compatible with being <code>const fn</code>), then we could make <code>derive(PartialEq)</code> do so...</p>



<a name="195631776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631776">(Apr 28 2020 at 21:49)</a>:</h4>
<p>I suppose there may be things the derived partial eq impl does today that are not expressible in <code>const fn</code></p>



<a name="195631800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631800">(Apr 28 2020 at 21:49)</a>:</h4>
<p>(e.g. inspecting the discriminant may not be legal in <code>const fn</code> today?)</p>



<a name="195631875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631875">(Apr 28 2020 at 21:50)</a>:</h4>
<p>its been a long time since I messed around with the innards of those derives...</p>



<a name="195631906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631906">(Apr 28 2020 at 21:50)</a>:</h4>
<p>It'd be nice if all <code>derive(PartialEq)</code> calls were const if the fields' <code>PartialEq</code> impls are.</p>



<a name="195631917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631917">(Apr 28 2020 at 21:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="236160">Asa Zeren</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195631673" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195631673">said</a>:</p>
<blockquote>
<p>How would that interact with #[derive(PartialEq)]? Would the derived impl be const sometimes, always, or never.</p>
</blockquote>
<p>(I guess I was hoping the answer was "always", but now I do not know if that's possible...)</p>



<a name="195631964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195631964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195631964">(Apr 28 2020 at 21:51)</a>:</h4>
<p>Right: Of course you hit a problem with type parameters</p>



<a name="195632009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632009">(Apr 28 2020 at 21:51)</a>:</h4>
<p>where a given generic type parameter may have a <code>PartialEq</code> implementation that is itself not a <code>const fn</code> impl ... sigh...</p>



<a name="195632049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632049">(Apr 28 2020 at 21:51)</a>:</h4>
<p>okay maybe this is all ridiculous then</p>



<a name="195632052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Asa Zeren <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632052">(Apr 28 2020 at 21:51)</a>:</h4>
<p>if partial eq only sometimes uses <code>const fn</code>s, then there would be no source level indication, and so changing a type (including transitively) would mysteriously break things, and make it very easy to break semver</p>



<a name="195632144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Asa Zeren <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632144">(Apr 28 2020 at 21:52)</a>:</h4>
<p>Perhaps one could go with a new trait <code>ConstPartialEq</code> or some such</p>



<a name="195632157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632157">(Apr 28 2020 at 21:52)</a>:</h4>
<p>another approach would be an opt-in of some kind</p>



<a name="195632196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632196">(Apr 28 2020 at 21:52)</a>:</h4>
<p>yeah, I was thinking more along the lines of <code>derive(PartialEq(const))</code>, but in any case</p>



<a name="195632239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632239">(Apr 28 2020 at 21:53)</a>:</h4>
<p>some way to actually signal intent</p>



<a name="195632264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632264">(Apr 28 2020 at 21:53)</a>:</h4>
<p>which, given how relatively rare generic constants are ... maybe that would be okay?</p>



<a name="195632271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Asa Zeren <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632271">(Apr 28 2020 at 21:53)</a>:</h4>
<p>The nice thing about a trait is that it would remove the 'ad-hoc' classification of types.</p>



<a name="195632275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632275">(Apr 28 2020 at 21:53)</a>:</h4>
<p>pretty hokey though</p>



<a name="195632291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632291">(Apr 28 2020 at 21:53)</a>:</h4>
<p>It feels like we need a more systematic way of handling <code>const</code> in traits.</p>



<a name="195632301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632301">(Apr 28 2020 at 21:53)</a>:</h4>
<p>(And functions, but especially traits.)</p>



<a name="195632317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632317">(Apr 28 2020 at 21:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195631285" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195631285">said</a>:</p>
<blockquote>
<p>I think that was what bothered me, that it introduced a kind of "class" of types</p>
</blockquote>
<p>yeah now I think I understand what <span class="user-mention" data-user-id="116009">@nikomatsakis</span> was getting at here</p>



<a name="195632373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632373">(Apr 28 2020 at 21:54)</a>:</h4>
<p>anyway gotta go afk</p>



<a name="195632385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195632385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195632385">(Apr 28 2020 at 21:54)</a>:</h4>
<p>sorry for stirring the pot. :)</p>



<a name="195654329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195654329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195654329">(Apr 29 2020 at 02:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629411" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195629411">said</a>:</p>
<blockquote>
<p>i.e. that supporting the cross-crate thing here is fine. (In particular, I'm betting that if there was some problem with it, <span class="user-mention silent" data-user-id="119009">eddyb</span> would have raised a ruckus with respect to this PR a long time ago...)</p>
</blockquote>
<p>we already leak properties cross-crate like whether the value needs destructors or whether it contains UnsafeCell values</p>



<a name="195654434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195654434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195654434">(Apr 29 2020 at 02:55)</a>:</h4>
<p>as for const generics, we don't want to dispatch to user code <em>at all</em>. it's just not worth it, from a typesystem-must-be-sound-at-any-cost perspective</p>



<a name="195654578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195654578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195654578">(Apr 29 2020 at 02:57)</a>:</h4>
<p>but we do want to limit the types we allow in const generics to those with structural Eq, to avoid confusing semantics, and limit primitive leaf values to those that are effectively plain integers (while references behave as newtypes, not pointers, because of their by-value-eq semantics)</p>



<a name="195689409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195689409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195689409">(Apr 29 2020 at 10:38)</a>:</h4>
<p>That last point is not obvious to me.</p>



<a name="195689488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195689488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195689488">(Apr 29 2020 at 10:39)</a>:</h4>
<p>By which I just mean: it avoids confusing semantics, but it shuts out use cases too, and I'm not sure what is best -- especially as "structural equality" is this "latent concept" right now and not something users can declare. And if it becomes something users can declare, then that's adding another thing to have to understand.</p>



<a name="195689566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195689566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195689566">(Apr 29 2020 at 10:40)</a>:</h4>
<p>Anyway I think it's a good question to defer for the moment, when it comes to const generics, which maybe implies it's ok to defer the question of match semantics too until we're further down the road.</p>



<a name="195708902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195708902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195708902">(Apr 29 2020 at 13:33)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> <a href="https://github.com/rust-lang/rust/issues/49146#issuecomment-617862124" title="https://github.com/rust-lang/rust/issues/49146#issuecomment-617862124">this comment by <span class="user-mention" data-user-id="124288">@oli</span> and some of the replies are relevant</a>, they talk about the 'opacity' of constant definitions vs const fn with respect to the "precise variant" analysis</p>



<a name="195739612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195739612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195739612">(Apr 29 2020 at 16:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195632291" title="#narrow/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343/near/195632291">said</a>:</p>
<blockquote>
<p>It feels like we need a more systematic way of handling <code>const</code> in traits.</p>
</blockquote>
<p>This in part seems like the focus of the <a href="https://github.com/rust-lang/rfcs/pull/2632" title="https://github.com/rust-lang/rfcs/pull/2632">generic parameters in const fn RFC</a>. Maybe it's worth starting up a lang WG to discuss these sorts of issues more comprehensively and holistically?</p>



<a name="195739763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195739763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195739763">(Apr 29 2020 at 16:57)</a>:</h4>
<p>(I'm definitely interested in being part of these discussions when they do happen.)</p>



<a name="195803709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195803709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195803709">(Apr 30 2020 at 06:55)</a>:</h4>
<p>I also recently discovered that pattern matching <a href="https://github.com/rust-lang/const-eval/issues/42" title="https://github.com/rust-lang/const-eval/issues/42">places an entire new set of soundness concerns on const-eval</a> that so far  we have not explicitly documented anywhere, and that I was not aware of...</p>



<a name="195803792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195803792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195803792">(Apr 30 2020 at 06:57)</a>:</h4>
<p>not sure if that has been discussed in this context already, but the fact that we do pattern-matching through arbitrary reference types places some serious restrictions on use of consts outside patterns. namely, it would otherwise be completely okay to have a const pointing to a (potentially mutable) static; with pattern matching however we must ensure that consts <em>transitively</em> do not point to anything mutable anywhere ever.</p>



<a name="195804131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195804131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195804131">(Apr 30 2020 at 07:01)</a>:</h4>
<p>Why would it ever be acceptable to have a reference to a mutable thing and still be able to mutate that thing?</p>



<a name="195804210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195804210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195804210">(Apr 30 2020 at 07:02)</a>:</h4>
<p>That seems like it violates the most fundamental property of the borrow checker.</p>



<a name="195878387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195878387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195878387">(Apr 30 2020 at 18:05)</a>:</h4>
<p>at leas mutating it through that reference should be fine, right?</p>



<a name="195878416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195878416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195878416">(Apr 30 2020 at 18:05)</a>:</h4>
<p>like, <code>&amp;mut SOMETHING_GLOBAL</code> <em>is</em> a constant value, and there seems to be no harm in letting people put it in a constant</p>



<a name="195878509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195878509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195878509">(Apr 30 2020 at 18:06)</a>:</h4>
<p>or, more likely, <code>&amp;SOMETHING_GLOBAL_WITH_INTERIOR_MUT</code></p>



<a name="195878596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20pattern%20match%20semantics%20%2367343/near/195878596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20pattern.20match.20semantics.20.2367343.html#195878596">(Apr 30 2020 at 18:07)</a>:</h4>
<p>if it wasn't for patterns, consts could refer to interior mutable statics just fine (and there are no aliasing issues because of <code>UnsafeCell</code>)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>